Skip to content

feat: stabilize SFTP and add secure SSH terminal integration - #2694

Open
bajrangCoder wants to merge 6 commits into
mainfrom
feat/sftp-improvements
Open

feat: stabilize SFTP and add secure SSH terminal integration#2694
bajrangCoder wants to merge 6 commits into
mainfrom
feat/sftp-improvements

Conversation

@bajrangCoder

Copy link
Copy Markdown
Member

Summary

This PR improves the reliability and security of Acode's SFTP integration and adds interactive SSH terminal support using the existing Maverick Synergy SSH library.

It addresses the SFTP lifecycle, cleanup, and path issues reported in:

SFTP reliability improvements

  • Prevent overlapping SFTP connection attempts.
  • Properly close previous SFTP and SSH connections before switching servers.
  • Reduce Maverick SFTP window sizes and asynchronous request limits for Android.
  • Improve handling of disconnected and partially initialized sessions.
  • Clean up SFTP files, folders, recents, and active editor references when a storage is removed.
  • Preserve URL path boundaries when removing or comparing remote entries.
  • Improve private-key and connection error handling.

SSH terminal integration

  • Add interactive SSH terminal sessions using Maverick SessionChannelNG.
  • Allocate an xterm-256color PTY and start an interactive remote shell.
  • Stream binary terminal output safely through the Cordova bridge.
  • Support password and private-key authentication.
  • Forward terminal input in order through a per-session native writer.
  • Synchronize terminal dimensions with the remote PTY.
  • Handle exit codes, connection errors, intentional closes, and plugin lifecycle cleanup.
  • Keep terminal connections independent from the global SFTP browser connection.
  • Add “Open SSH Terminal” to saved SFTP storage and open-folder context menus.
  • Prevent remote hosts from invoking Acode's local OSC 7777 file-opening protocol.
  • Keep remote-terminal creation internal; it is not exposed through the public Acode plugin API.

Secure SFTP profiles

Previously, SFTP URLs could contain usernames, passwords, key-file paths, and passphrases.

This PR replaces persisted connection URLs with opaque identifiers:

sftp://profile-<uuid>/remote/path

The corresponding connection profile is stored natively and encrypted using:

  • Android Keystore-managed AES key
  • AES/GCM/NoPadding
  • Random IV per profile encryption
  • Profile ID as authenticated additional data

Encrypted profiles contain the server details and authentication material. Profile reads exposed to JavaScript return metadata only and never return passwords, passphrases, or private-key contents.

Private-key files selected for new profiles are read by the native plugin and stored inside the encrypted profile instead of being copied into an SFTP URL.

Migration

On startup, legacy SFTP URLs are migrated across:

  • Saved storages
  • Remembered files
  • Remembered folders
  • Recent files
  • Recent folders
  • File-browser state

Migration behavior is intentionally conservative:

  • Repeated URLs using the same credentials reuse the migrated profile.
  • Paths are preserved while credentials and query parameters are removed.
  • A failed profile migration leaves the legacy URL unchanged.
  • App-private plaintext key copies are removed only after successful migration.
  • Shared profiles are not deleted while another saved storage still references them.

@github-actions github-actions Bot added the enhancement New feature or request label Aug 8, 2026
@bajrangCoder
bajrangCoder marked this pull request as ready for review August 8, 2026 03:27
@UnschooledGamer UnschooledGamer added the S/FTP Issues and Pull requests related to SFTP/FTP. label Aug 8, 2026
@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR moves SFTP credentials into encrypted native profiles, migrates existing persisted SFTP URLs, improves connection and removal lifecycle handling, and adds interactive SSH terminal sessions.

  • Adds Android Keystore-backed encrypted SFTP profile storage and legacy URL migration.
  • Adds native Maverick SSH shell channels with terminal input, output, resize, exit, and cleanup handling.
  • Updates SFTP storage, recents, folder, editor, and file-browser state to use opaque profile URLs.
  • Adds focused URL and profile-migration tests.

Confidence Score: 5/5

The PR appears safe to merge within the scope of this follow-up review.

No blocking failure remains in the eligible follow-up findings.

Important Files Changed

Filename Overview
src/lib/sftpProfiles.js Implements recursive migration of persisted legacy SFTP URLs into opaque native profile references with credential deduplication and post-migration key cleanup.
src/plugins/sftp/src/com/foxdebug/sftp/SftpSecurityStore.java Adds Android Keystore-backed AES-GCM encryption and authenticated native persistence for SFTP profiles.
src/plugins/sftp/src/com/foxdebug/sftp/Sftp.java Extends the native plugin with profile-based SFTP connections and independently managed interactive SSH shell sessions.
src/plugins/sftp/src/com/foxdebug/sftp/SftpProfileEditor.java Adds native profile editing and private-key selection for SFTP authentication.
src/components/terminal/terminal.js Connects xterm to native SSH shell events and forwards terminal input, resize, and close operations.
src/components/terminal/terminalManager.js Adds internal remote-terminal creation and integrates SSH sessions with the existing terminal tab lifecycle.
src/fileSystem/sftp.js Replaces URL-embedded credentials with profile identities and serializes profile connection attempts.
src/pages/fileBrowser/fileBrowser.js Integrates secure SFTP profile creation, removal, and SSH terminal actions into the file browser.
src/utils/Url.js Updates URL handling to preserve remote path boundaries needed by opaque SFTP profile URLs.
tests/unit/sftpProfiles.test.js Covers profile URL construction, migration deduplication, path preservation, and migration failure behavior.

Sequence Diagram

sequenceDiagram
    participant App as Acode startup
    participant Migration as sftpProfiles.js
    participant Native as SFTP Cordova plugin
    participant Store as Encrypted profile store
    participant Browser as File browser / fsOperation
    participant Terminal as SSH terminal

    App->>Migration: Migrate persisted legacy SFTP URLs
    Migration->>Native: Save credential profile
    Native->>Store: Encrypt and persist profile
    Store-->>Native: profile ID
    Native-->>Migration: profile ID
    Migration-->>App: Persist sftp://profile-ID/path

    Browser->>Native: Connect using profile ID
    Native->>Store: Decrypt profile internally
    Native-->>Browser: SFTP connection and operations

    Terminal->>Native: Open shell using profile ID
    Native-->>Terminal: ready
    Native-->>Terminal: base64 terminal data
    Terminal->>Native: ordered input and PTY resize
    Native-->>Terminal: exit or error
Loading

Reviews (2): Last reviewed commit: "perf(sftp): run legacy profile migration..." | Re-trigger Greptile

RohitKushvaha01

This comment was marked as outdated.

Comment thread src/plugins/sftp/src/com/foxdebug/sftp/SftpSecurityStore.java
@UnschooledGamer UnschooledGamer added the CI: RUN ON-DEMAND PREVIEW RELEASES Triggers an on-demand preview build for this pull request via CI workflow. label Aug 8, 2026
@github-actions github-actions Bot removed the CI: RUN ON-DEMAND PREVIEW RELEASES Triggers an on-demand preview build for this pull request via CI workflow. label Aug 8, 2026
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Preview Release for this, has been built.

Click here to view that github actions build

@bajrangCoder

This comment was marked as outdated.

Comment thread src/pages/fileBrowser/fileBrowser.js Fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request S/FTP Issues and Pull requests related to SFTP/FTP.

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

The app crashes when loading SFTP files Deleted SFTP folders still tries reconnect

4 participants